<template>
    <div>
        <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect"
                 v-if="readyShow">
            <el-menu-item index="1" style="width: 50%">会议入座</el-menu-item>
            <el-menu-item index="2" style="width: 50%">会议详情</el-menu-item>
        </el-menu>
        <div v-if="readyShow">
            <meeting-videos v-show="meetingVideos" :siteList="siteList"></meeting-videos>
            <meeting-files v-show="meetingFiles" :item="item" :endTime="endTime" :fileids="fileids" :signState="signState"
                           :meetingFile="meetingFile"></meeting-files>
            <!-- <vote-list v-show="voteList" style="width: 100%"></vote-list>-->
        </div>

        <!--<el-dialog title="签到页面" :visible.sync="dialogFormVisible" width="85%" center>
            <el-form :model="form">
                <el-form-item label="会议 : ">
                    <el-select v-model="form.meetingJoin" placeholder="是否参加现场会议">
                        <el-option value="参加现场会议"></el-option>
                        <el-option value="不参加现场会议"></el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" icon="el-icon-edit-outline" style="margin-left: 10%" @click="toSign"
                           plain> 签 到
                </el-button>
                <i class="el-icon-warning" style="font-size:11px;display: block;margin-top:3%"> 点击签到后进入在线会议系统</i>
            </div>
        </el-dialog>-->
    </div>
</template>

<script>
    import MeetingVideos from './components/meeting-videos.vue'
    import MeetingFiles from './components/meeting-files.vue'
    // import VoteList from './components/vote-list.vue'
    import util from 'assets/js/util.js'

    export default {
        data() {
            return {
                siteList: [],
                item: {
                    name: '',
                    startTime: '',
                    endTime: '',
                },
                meetingFile: {
                    compressFileUrl: '',
                },
                fileids: '',
                name: '',
                activeIndex: '1',
                meetingVideos: true,
                meetingFiles: false,
                voteList: false,
                readyShow: false,
                signState: 0,
                meetingId: 0,
                creditorId: 0,
                dialogFormVisible: false,
                endTime: '',
            }
        },
        mounted() {
            this.meetingId = util.getUrlParam(document.location.href, 'meetingId');
            this.creditorId = util.getUrlParam(document.location.href, 'creditorId');

            const _self = this;
            util.ajax({
                url: '/meeting/info',
                params: {meetingId: util.getUrlParam(document.location.href, 'meetingId')},
                success: function (data) {
                    _self.id = data.data.id;
                    _self.meetingFile.compressFileUrl = data.data.compressFileUrl;
                    _self.fileids = data.data.fileids;
                    _self.signState = data.data.signState;
                    _self.meetingFile.name = data.data.name;
                    _self.item.description = data.data.description;
                    _self.linkUrl = data.data.linkUrl;
                    _self.item.startTime = util.formatDateDetail(data.data.startTime) || '';
                    _self.item.endTime = util.formatDateDetail(data.data.endTime) || '';
                    _self.item.signStartTime = util.formatDateDetail(data.data.signStartTime) || '';
                    _self.endTime = data.data.endTime || '';
                    _self.readyShow = true;
                },
            });

            util.ajax({
                url: '/meeting/place/list',
                params: {meetingId: this.meetingId},
                success: function (data) {
                    data.data.content.forEach(_meetingPlace => {
                        _self.siteList.push({
                            id: _meetingPlace.id,
                            name: _meetingPlace.name,
                            time: util.formatDateDetail(_meetingPlace.startTime) + '—' + util.formatDateDetail(_meetingPlace.endTime),
                            remainderSeatNum: _meetingPlace.remainderSeatNum,
                            state: _self.goState(_meetingPlace.state),
                            stateStr:_self.goStateStr(_meetingPlace.state),
                        })
                    });
                },
            });
        },
        methods: {
            handleSelect: function (key, keyPath) {
                this.meetingVideos = false;
                this.meetingFiles = false;

                switch (key) {
                    case '1':
                        this.meetingVideos = true;
                        break;
                    case '2':
                        this.meetingFiles = true;
                        break;
                }
            },
            goState: function (type) {
                let typeText = '';
                switch (type) {
                    case 0:
                        typeText = '入座';
                        break;
                    case 1:
                        typeText = '弃座';
                        break;
                    default:
                        break
                }
                return typeText
            },
            goStateStr: function (type) {
                let typeText = '';
                switch (type) {
                    case 0:
                        typeText = '未入座';
                        break;
                    case 1:
                        typeText = '已入座';
                        break;
                    default:
                        break
                }
                return typeText
            },
            /* toSign: function (attendState) {
                 const _self = this;
                 console.log(this.form)
                 util.ajax({
                     url: '/meeting/sign',
                     params: {
                         meetingId: util.getUrlParam(document.location.href, 'meetingId'),
                         attendState: _self.form.meetingJoin === "不参加现场会议" ? 0 : 1
                     },
                     success: function (data) {
                         _self.dialogFormVisible = false;
                         _self.readyShow = true;
                     },
                 });
             }*/
        },
        components: {
            MeetingVideos,
            MeetingFiles,
            /* VoteList*/
        }
    }
</script>

<style>
    .el-menu li {
        text-align: center;
    }
</style>
